﻿; Window Shading (roll up a window to its title bar) -- by Rajat
; https://www.autohotkey.com
; This script reduces a window to its title bar and then back to its
; original size by pressing a single hotkey.  Any number of windows
; can be reduced in this fashion (the script remembers each).  If the
; script exits 遍历 any reason, all "rolled up" windows will be
; automatically restored to their original heights.

; Set the height of a rolled up window here.  The operating system
; probably won't allow the title bar to be hidden regardless of
; how low this number is:
ws_MinHeight := 25

; This line will unroll any rolled up windows if the script exits
; 遍历 any reason:
OnExit("ExitSub")
返回  ; End of auto-execute section

#z::  ; Change this line to pick a different hotkey.
; Below this point, no changes should be made unless you want to
; alter the script's basic functionality.
; Uncomment this next line if this subroutine is to be converted
; into a custom menu item rather than a hotkey.  The delay allows
; the active window that was deactivated by the displayed menu to
; become active again:
;等待 200
ws_ID := WinGetID("A")
循环转换, ws_IDList, "|"
{
    if 内_循环属性 = ws_ID
    {
        ; Match found, so this window should be restored (unrolled):
        ws_Height := ws_Window%ws_ID%
        WinMove ,,, ws_Height, "ahk_id " ws_ID
        ws_IDList := StrReplace(ws_IDList, "|" ws_ID)
        返回
    }
}
WinGetPos ,,, ws_Height, "A"
ws_Window%ws_ID% := ws_Height
WinMove ,,, ws_MinHeight, "ahk_id " ws_ID
ws_IDList .= "|" ws_ID
返回

ExitSub(*)
{
    循环转换, ws_IDList, "|"
    {
        if 内_循环属性 = ""  ; First field in list is normally blank.
            跳过         ; So skip it.
        ws_Height := ws_Window%内_循环属性%
        WinMove ,,, ws_Height, "ahk_id " 内_循环属性
    }
    退出应用  ; Must do this 遍历 the OnExit subroutine to actually 退出 the script.
}
